<?php

//no direct access
defined ('_JEXEC') or die ('Restricted access');

class modImageSliderHelper
{

	function readFolder($directory)
	{
		$path 				= "images/sunrise/";		

		$allowed_formats 	= array("jpg", "jpeg", "JPG", "JPEG", "png", "PNG", "gif", "GIF");
		$exclude_files 		= array(
									"thumb",	//Exclude this folder and just get the image files
									".svn",
									"_derived",
									"_private",
									"_vti_cnf",
									"_vti_pvt",
									"vti_script",
									"_vti_txt"
									); // add any other folders or files you wish to exclude from the gallery.		

		$directory = $path.$directory; 

        if($handler = opendir($directory))
        { 
            while (($sub = readdir($handler)) !== FALSE) 
            { 
                  
                  if ($sub != "." && $sub != ".." && $sub != "Thumb.db" && array_search($sub, $exclude_files)===false) 
                  {
						$ext = substr($sub, strrpos($sub, ".")+1);
						if(is_file($directory."/".$sub) && array_search($ext, $allowed_formats)!==false )  
	                    {
                  	
	                    	$image = modImageSliderHelper::getImageInfo($directory."/".$sub);
	                    	$image["name"] = $sub; 
	                    	$files[] = $image;
	                    } 
	                    elseif(is_dir($directory."/".$sub))  modImageSliderHelper::readFolder($directory."/".$sub); 
                   } 
            } 
            
            closedir($handler); 
        }

        return $files;
	}     
    
	function getImageInfo($file)
	{
		$image = getimagesize($file);
		$info["width"] = $image[0];
		$info["height"] = $image[1];
		return $info;
	}    
}


?>